// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   DataSourceFactory.java

package org.jawa.database;

import javax.sql.DataSource;

import org.jawa.database.DbConnectionManager;

public class DataSourceFactory {

	private static DataSource dataSource;

	public DataSourceFactory() {
		dataSource = null;
	}

	public void init() {
		if (null == dataSource) {
			dataSource = DbConnectionManager.getDataSource();
		}
	}

	public DataSource getDataSource() {
		return dataSource;
	}

	public void destroy() throws Exception {
		if (DbConnectionManager.getConnectionProvider() != null)
			DbConnectionManager.destroyConnectionProvider();
		dataSource = null;
	}

	public void restart() {
		try {
			destroy();
			init();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
